#include "UdpServer.hpp"
#include "Dict.hpp"
#include <memory>

std::string defaultfunc(const std::string& msg)
{
    std::string ret = "hello, ";
    ret += msg;
    return ret;
}

int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        std::cerr << "ERROR:" << "Usage " << argv[0] << " port" << std::endl;
        exit(1);
    }

    Dict dict;
    dict.DictLoad();

    //std::string ip = argv[1];
    uint16_t port = std::stoi(argv[1]);
    std::unique_ptr<UdpServer> p = std::make_unique<UdpServer>(port, [&dict](const std::string& word)->std::string
    {
        return dict.translate(word);
    });
    p->Init();
    p->Start();
    return 0;
}